package com.cxsj.project.system.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cxsj.framework.web.domain.JsonResult;
import com.cxsj.project.system.entity.Comment;
import com.cxsj.project.system.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Dempsey
 * @since 2021-06-15
 */
@RestController
@RequestMapping("/api/comment")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    //接口1：get请求('/api/comment/origin')
    //返回所有数据，对象数组
    @GetMapping("/origin")
    public JsonResult list() {
        List<Comment> list = commentService.list();
        return JsonResult.result(list);
    }

    //接口2：get请求('/api/comment/new')
    //返回过滤后的数据(isfilter===1)
    @GetMapping("/new")
    public JsonResult new1() {
        List<Comment> list = commentService.list(new QueryWrapper<Comment>().eq("isfilter", 1));
        return JsonResult.result(list);
    }
}

